package cn.nohan.funplay.module.member.mongo.common;

import java.io.Serializable;

/**
 * @author caozhipeng
 * @date 2025/7/11
 */
public class Result implements Serializable{

    private Integer code;

    private String message;

    private Object data;

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    public static Result fail(RuntimeException exception) {
        return new Result(500, exception.getMessage());
    }

    public static Result fail(Exception exception) {
        return new Result(500, exception.getMessage());
    }




    public static Result success() {
        return new Result(200,"success");
    }

    public static Result success(Object data) {
        return new Result(200,"success", data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
